package com.template.domain.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import com.template.common.lang.Regexp;
import com.template.common.validgroup.Create;
import com.template.common.validgroup.Update;
import com.template.domain.entity.base.BaseEntity;
import com.template.config.mybatisflex.listener.MyInsertListener;
import com.template.config.mybatisflex.listener.MyUpdateListener;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体类。
 *
 * @author dong
 * @since 2023-09-03
 */
@Getter
@Setter
@Accessors(chain = true)
@Table(value = "sys_user", onInsert = MyInsertListener.class, onUpdate = MyUpdateListener.class)
public class SysUser extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Id
    @NotNull(message = "用户id为必传项", groups = Update.class)
    private Long id;

    @NotBlank(message = "请输入用户姓名", groups = Create.class)
    private String name;

    private String nickname;

    @NotBlank(message = "请输入账号", groups = Create.class)
    private String account;

    @Column(isLarge = true)
    @Pattern(regexp = Regexp.PASSWORD, message = "密码必须为6-18位数字/字符/符号的组合", groups = Create.class)
    private String password;

    private Long avatar;

    private String phone;

    private String email;

    private String securPhone;

    private String securEmail;

    private String signature;

    private String area;

    private LocalDateTime lastLogin;

    private Boolean status;

}
